package com.company.huisuo.biz.dialog

import android.app.Activity
import android.view.WindowManager
import com.company.huisuo.R
import com.company.huisuo.base.BaseCenterPopupView
import com.company.huisuo.databinding.DialogMemberRechargeCustomBinding


class MemberRechargeCustomDialog(
    activity: Activity, val okClick: (Int) -> Unit
) : BaseCenterPopupView<DialogMemberRechargeCustomBinding>(
    activity
) {
    override val getLayoutId: Int
        get() = R.layout.dialog_member_recharge_custom
    override val getViewBinding: DialogMemberRechargeCustomBinding
        get() = DialogMemberRechargeCustomBinding.bind(contentView)

    override fun initData() {
        // 阻止软键盘自动弹出
        dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)

        mBinding.ivClose.setOnClickListener {
            dismiss()
        }
        mBinding.tvOk.setOnClickListener {
            val money = if (mBinding.etMoney.text.isNullOrEmpty()) {
                0
            } else {
                mBinding.etMoney.text.toString().toInt()
            }
            okClick.invoke(money)
            dismiss()
        }
    }
}